package com.zx.mes.hyl.common.util.jwt;

/**
 * 实现接口JWTInfoI
 * @author hyl
 * @date 2017-12-16
 */
public class JWTInfo implements JWTInfoI{

    private String username;
    private String userId;
    private String name;


    public JWTInfo(String username, String userId, String name) {
        this.username = username;
        this.userId = userId;
        this.name = name;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getUniqueName() {
        return username;
    }

    @Override
    public String getId() {
        return userId;
    }

    @Override
    public String getName() {
        return name;
    }

    /**
     * 重写equals方法
     * @param o Object
     * @return boolean
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {return false;}

        JWTInfo jwtInfo = (JWTInfo) o;

        if (!username.equals(jwtInfo.username)) {return false;}
        return userId.equals(jwtInfo.userId);
    }

    @Override
    public int hashCode() {
        int result = username.hashCode();
        result = 31 * result + userId.hashCode();
        return result;
    }
}
